package com.edu.exam.enums.system;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 存储类型枚举
 * 管理文件存储的类型定义
 *
 * @author System
 * @version 1.0.0
 */
public enum StorageType implements BaseEnum {

    LOCAL("LOCAL", "本地存储"),
    ALIYUN_OSS("ALIYUN_OSS", "阿里云OSS"),
    QINIU_KODO("QINIU_KODO", "七牛云Kodo"),
    TENCENT_COS("TENCENT_COS", "腾讯云COS"),
    MINIO("MINIO", "MinIO"),
    AWS_S3("AWS_S3", "AWS S3"),
    GOOGLE_CLOUD("GOOGLE_CLOUD", "谷歌云"),
    AZURE_BLOB("AZURE_BLOB", "Azure Blob"),
    FTP("FTP", "FTP服务器"),
    SFTP("SFTP", "SFTP服务器"),
    NFS("NFS", "网络文件系统"),
    DATABASE("DATABASE", "数据库存储");

    private final String code;
    private final String description;

    StorageType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static StorageType fromCode(String code) {
        for (StorageType value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        throw new IllegalArgumentException("Unknown storage type code: " + code);
    }
    public static StorageType fromDescription(String description) {
        for (StorageType value : values()) {
            if (value.getDescription().equals(description)) {
                return value;
            }
        }
        throw new IllegalArgumentException("Unknown storage type description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}